package org.cid54.bukkit.command;

import org.cid54.bukkit.command.util.PlayerCommand;
import org.bukkit.Material;
import org.bukkit.event.player.PlayerChatEvent;
import org.cid54.bukkit.Cid54PlayerListener;

/**
 *
 * @author Cid54
 */
public class FindCommand implements PlayerCommand {

    public boolean execute(String command, PlayerChatEvent event, Cid54PlayerListener listener) {
        String pattern = command.split(" ")[1];

        for (Material m : Material.values()) {

            if (m.name().toLowerCase().contains(pattern)) {
                event.getPlayer().sendMessage(m.getId() + " : " + m.name());
            }

        }
        return true;
    }

    public String getCommand() {
        return "find";
    }

    public String getHelpText() {
        return "Finds items with this pattern in the name";
    }
}
